package com.zixi.ai.chat.controller;

import com.zixi.ai.chat.dto.ChatDto;
import com.zixi.ai.chat.service.IChatService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @author wfg
 */
@RestController
@Tag(name = "Chat APIs")
@RequestMapping("/api/v1/chat")
@RequiredArgsConstructor
public class ZxChatController {
    private final IChatService chatService;

    @PostMapping("/chat")
    @Operation(summary = "基本聊天")
    public Flux<String> chat(
            HttpServletResponse response,
            @Validated @RequestBody ChatDto chatDto) {
        return chatService.chat(chatDto.getChatId(), chatDto.getAiLlmId(), chatDto.getMsg());
    }

    @PostMapping("/deep-thinking/chat")
    @Operation(summary = "深度思考聊天")
    public Flux<String> deepThinkingChat(
            HttpServletResponse response,
            @Validated @RequestBody ChatDto chatDto) {
        response.setCharacterEncoding("UTF-8");
        return chatService.deepThinkingChat(chatDto.getChatId(), chatDto.getAiLlmId(), chatDto.getMsg());
    }
}
